import { StdNoteTextDataV2 } from './note'
import { v4 as uuid } from 'uuid'
import { StdTextDataV2 } from './textData'

export class StdExampleV2 {
  constructor({ dataId, contentNumber, dataLang = 'zh', textData, isResetNumber = false }) {
    // 数据唯一标识
    this.dataId = dataId || uuid()
    // 示例编号 - 前端预留
    this.contentNumber = contentNumber
    // 中英文区分 zh:中文，en:英文
    this.dataLang = dataLang
    // 具体内容类型contentType = text（默认文本) sup(上标) sub（下标）
    this.textData = new StdTextDataV2(textData)
    // 是否是重新编号
    this.isResetNumber = isResetNumber
  }
}

// 示例和注的文本textData解析
export class StdExampleTextDataV2 extends StdNoteTextDataV2 {
  constructor(node) {
    super(node)
    this.contentList = []
  }
  get data() {
    const attr = this.node?.dataset
    const textData = new StdNoteTextDataV2(this.node).data
    return {
      dataId: attr?.id,
      dataLang: attr?.lang,
      contentNumber: attr?.number,
      isResetNumber: Number(attr?.isResetNumber) ? true : false,
      textData
    }
  }
}
